import {defineStore} from "pinia";
import {getListApi} from "../serves";
import type {
  Children,
  ChinaAdd,
  ChinaTotal,
  RootObject,
  StatisGradeCityDetail,
} from "./type";
export const useList = defineStore({
  id: "counter",
  state: () => ({
    list: <RootObject>{},
    item: <Children[]>[],
    chinaAdd: <ChinaAdd>{},
    chinaTotal: <ChinaTotal>{},
    cityDetail: <StatisGradeCityDetail[]>[],
  }),

  actions: {
    getList() {
      return getListApi().then((res: any) => {
        this.list = res.data;
        console.log(res.data);
        this.chinaAdd = this.list.diseaseh5Shelf.chinaAdd;
        this.chinaTotal = this.list.diseaseh5Shelf.chinaTotal;
        this.cityDetail = this.list.statisGradeCityDetail.slice(0, 10);
      });
    },
  },
});
